package com.xmutca.sso.server.web;

import com.xmutca.core.common.Results;
import com.xmutca.sso.api.server.AccountService;
import com.xmutca.sso.common.Principal;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author: 彭伟煌(pengweihuang@xmutca.com)
 * @create: 2016-08-31 15:27
 */
@Controller
@RequestMapping("/permissions")
public class PermissionController {

    @Autowired
    private AccountService accountService;

    /**
     * 查询所有的菜单
     * @return
     */
    @ResponseBody
    @RequestMapping
    public Results<?> queryPermissions() {
        Principal principal = (Principal) SecurityUtils.getSubject().getPrincipal();
        return accountService.queryPermission(principal.getId());
    }
}
